package com.tpp.service.impl;

import com.tpp.dao.TppMovieDao;
import com.tpp.pojo.TppMovie;
import com.tpp.pojo.baseVo.BaseResult;
import com.tpp.service.TppMovieService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class TppMovieServiceImpl implements TppMovieService {

    @Autowired
    TppMovieDao tppMovieDao;

//    @Override
//    public BaseResult findAll() {
////        Date date = new Date();
//////        SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMdd");
//////        int format = Integer.parseInt(formatter.format(date).toString());
////         long time = date.getTime();
////
////         List<TppMovie> all = tppMovieDao.findAll();
////        for (TppMovie ts:all
////             ) {
////             Date releaseTime = ts.getReleaseTime();
////             long time1 = releaseTime.getTime();
////            if (time1>time){
////
////                tppMovie.setMovieState(1);
////                int i = tppMovieDao.updateMovieState(tppMovie);
////                System.out.println(i);
////
////
////             BaseResult baseResult = new BaseResult();
////            List<TppMovie> all1 = tppMovieDao.findAll();
////            baseResult.setCode(1);
////            baseResult.setData(all1);
////            baseResult.setMsg("未上映");
////            return baseResult;
////        }
////        }
//        return null;
//
//    }

    @Override
    public BaseResult findByMovieWei() {
        BaseResult baseResult = new BaseResult();
        List<TppMovie> byMovieWei = tppMovieDao.findByMovieWei();
        baseResult.setMsg("即将上映");
        baseResult.setCode(1);
        baseResult.setData(byMovieWei);
        return baseResult;
    }

    @Override
    public BaseResult findByMovieHeat() {
        BaseResult baseResult = new BaseResult();
        List<TppMovie> byMovieHeat = tppMovieDao.findByMovieHeat();
        baseResult.setMsg("热映");
        baseResult.setCode(1);
        baseResult.setData(byMovieHeat);
        return baseResult;
    }

    @Override
    public BaseResult findMovieScore() {
        BaseResult baseResult = new BaseResult();
        List<TppMovie> movieScore = tppMovieDao.findMovieScore();
        baseResult.setMsg("排行榜");
        baseResult.setCode(1);
        baseResult.setData(movieScore);
        return baseResult;
    }

    @Override
    public BaseResult findByMovieOne(Integer movieId) {
        BaseResult baseResult =new BaseResult();
        TppMovie byMovieOne = tppMovieDao.findByMovieOne(movieId);
        baseResult.setCode(1);
        baseResult.setData(byMovieOne);
        baseResult.setMsg("电影详情");
        return baseResult;
    }
}